<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav main-header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            无任务配送
        </div>
    </header>
    <div class="aui-bar aui-bar-nav sub-header"></div>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;padding-bottom: 50px;">
        <div class="white_background">
            <ul class="aui-list aui-form-list">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <input type="text" class="aui-input" placeholder="请扫描箱号" style="width: 80%;font-size: 16px;"
                            id="boxnum" onclick="getIdSelector();" />
                        <i class="aui-input-addon aui-iconfont aui-icon-scan "
                            style="padding-right:10px;font-size: 1.6rem" onclick="doScan();"></i>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">调入库位</div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="选择/扫描 调入库位" id="relWorkCellCode" value=""
                                onclick="getIdSelector();" />
                        </div>
                        <i id="relCellSelect" class="aui-input-addon aui-iconfont aui-icon-right"
                            onclick="goSelectWorkCell('2')"></i>
                    </div>
                </li>
                <div class="aui-btn aui-btn-info aui-btn-block"><input type="text" class="aui-input"
                        style="width: 95%;font-size: 16px;color:white" id="message" /></div>

                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width:100%">扫描箱数：</div>
                        <div class="aui-list-item-input" style="margin-left:5%">
                            <input type="text" id="num" value="" disabled="true" style='color:red' />
                        </div>
                        <div class="aui-list-item-label" style="width:100%">物料总数：</div>
                        <div class="aui-list-item-input" style="margin-left:5%">
                            <input type="text" id="mrlnum" value="" disabled="true" style='color:red' />
                        </div>
                    </div>
                </li>
            </ul>



        </div>
        <ul class="ui-selectee" id="tbodyHtml">

        </ul>
    </div>
    <footer class="aui-bar aui-bar-tab" id="footer">
        <div class="aui-btn aui-btn-info aui-btn-block" style="margin:0 5%;width: 90%;" onclick="beforeSave()"
            id="submitButton">创建配送单</div>

    </footer>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/clickThrottle.js"></script>
<script type="text/javascript">
    //光标所在id
    //光标所在id
    var idSelector = "";
    var workCellGid = ""; //调出库位GID
    var workCellCode = ""; //调出库位编码
    var workCellName = ""; //调出库位名称
    var relWorkCellGid = ""; //调入库位GID
    var relWorkCellCode = ""; //调入库位编码
    var relWorkCellName = ""; //调入库位名称

    var scanRule = ""; //条码解析规则

    var workcell; //菜单路由参数 源库位编码
    var relworkcell; //菜单路由参数 调入库位编码
    var subBussinessType = "";//库间转移子业务类型

    var arrSave = [];
    var num = 0;
    var mrlnum = 0;
    var flagMsg = "";
    //初始化查询仓库下拉框
    apiready = function () {

        $("#boxnum").focus();
        idSelector = "boxnum";

        var query = api.pageParam.query;
        workcell = query.workcell;
        relworkcell = query.relworkcell;
        var title = query.title;
        var cellDis = query.cellDis;
        var relcellDis = query.relcellDis;
        var remarks = query.remarks;
        subBussinessType = query.subBussinessType;
        if (title != undefined && title != null && title != "") {
            document.getElementById("title").innerHTML = title;
        }
        if (remarks != undefined && remarks != null && remarks != "") {
            document.getElementById("remarks").innerHTML = remarks;
        }
        if (cellDis != undefined && cellDis != null && cellDis == "Y") {
            $("#workCellCode").attr('disabled', true);
            //设置库位选择点击事件无效
            document.getElementById("cellSelect").onclick = function () { };
        }
        if (relcellDis != undefined && relcellDis != null && relcellDis == "Y") {
            $("#relWorkCellCode").attr('disabled', true);
            //设置库位选择点击事件无效
            document.getElementById("relCellSelect").onclick = function () { };
        }
        if (workcell != undefined && workcell != null && workcell != "") {
            idSelector = "workCellCode";
            //查询调出库位
            getWorkCell(workcell, idSelector, "1");
        }
        if (relworkcell != undefined && relworkcell != null && relworkcell != "") {
            idSelector = "relWorkCellCode";
            //查询调入库位
            getWorkCell(relworkcell, idSelector, "2");
        }
        if (relworkcell != undefined && relworkcell != null && relworkcell != "") {
            idSelector = "relWorkCellCode";
            //查询调入库位
            getWorkCell(relworkcell, idSelector, "2");
        }
        $("#num").val(0);
        $("#mrlnum").val(0);
        //查询条码解析规则
        initScanRule();
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    //查询扫描规则
    function initScanRule() {
        var serverUrl = localStorage.getItem('serverUrl');
        var un = localStorage.getItem("un");
        var url = serverUrl + "/app/getTmScanRule";
        var data = {
            values: {
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    scanRule = myobj.scanRule
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {
            //1：调出库位
            if (idSelector == 'workCellCode') {

                $("#workCellCode").val(ret);
                //查询调出库位
                getWorkCell(ret, idSelector, "1");

                //24：调入库位
            } else if (idSelector == 'relWorkCellCode') {

                $("#relWorkCellCode").val(ret);
                //查询调入库位
                getWorkCell(ret, idSelector, "2");

                //5：扫描条码
            } else if (idSelector == 'boxnum') {
                // $("#boxnum").blur();
                $("#boxnum").attr('disabled', true);
                tmSplit(ret);
            }
        });
    }

    //7:库位扫描校验
    function getWorkCell(code, inputId, flag) {
        var un = localStorage.getItem("un");
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCell";
        var data = {
            values: {
                flag: "out_kj", //库内库间标识（out_kn库内  out_kj库间,in_rk入库出库）
                workCenterGid: "", //仓库GID
                workCellCode: code, //库位编码
                relWorkCellGid: "", //调入库位
                tm: "",
                workCellFlag: "", //原库位调入库位flag
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {
                    var list = eval(myobj.list);

                    //源库位
                    if (flag == "1") {

                        workCellGid = list[0].workCellGid;
                        workCellCode = list[0].workCellCode + ":" + list[0].workCellName;
                        workCellName = list[0].workCellName;
                        document.getElementById(inputId).value = workCellCode;
                        $("#boxnum").attr('disabled', false);
                        $("#boxnum").focus();
                        idSelector = "boxnum";

                        //调入库位
                    } else if (flag == "2") {

                        relWorkCellGid = list[0].workCellGid;
                        relWorkCellCode = list[0].workCellCode + ":" + list[0].workCellName;
                        relWorkCellName = list[0].workCellName;
                        document.getElementById(inputId).value = relWorkCellCode;
                        $("#workCellCode").focus();
                        idSelector = "workCellCode";
                    }
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#" + inputId).focus();
                    $("#" + inputId).select();
                }
            }
        });
    }

    //8：选择库位
    function goSelectWorkCell(workCellFlag) {
        var tm = $("#tm").val();
        api.openWin({
            name: 'uwmSelectWorkCell',
            url: 'uwmSelectWorkCell.html',
            pageParam: {
                flag: "out_kj",
                name: "taskFreeDistribution",
                tm: tm,
                workCenterGid: "",
                relWorkCellGid: relWorkCellGid,
                workCellFlag: workCellFlag
            }
        });
    }

    //库位选择后回调函数
    function setWorkCell(id, code, name, workCellFlag) {

        //源库位
        if (workCellFlag == "1") {

            workCellGid = id;
            workCellCode = code;
            workCellName = name;
            document.getElementById('workCellCode').value = code + ":" + name;

            //调入库位
        } else if (workCellFlag == "2") {

            relWorkCellGid = id;
            relWorkCellCode = code;
            relWorkCellName = name;
            document.getElementById('relWorkCellCode').value = code + ":" + name;
            $("#workCellCode").focus();
            var e = "workCellCode";
            idSelector = e;
        }
    }

    //9；PDA自带扫描回车事件-源库位
    $("#workCellCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            $("#workCellCode").val(sm);
            getWorkCell(sm, "workCellCode", "1");
        }
    });

    //10；PDA自带扫描回车事件-调入库位
    $("#relWorkCellCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            $("#relWorkCellCode").val(sm);
            getWorkCell(sm, "relWorkCellCode", "2");
        }
    });


    function beforeSave() {
        api.confirm({
            title: '温馨提示',
            msg: '您确定要创建配送单吗？',
            buttons: ['确定', '取消']
        }, function (ret, err) {
            if (ret.buttonIndex == 1) {
                save()
            }
        });
    }

    //保存按钮
    function save() {
        if (!clickThrottle()) {
            return;
        }
        const submitButton = document.getElementById('submitButton');


        submitButton.style.pointerEvents = "none"
        //调入库位非空校验
        if (relWorkCellGid == "" || relWorkCellGid == null || relWorkCellGid == undefined) {
            api.toast({
                msg: '请选择/扫描 调入库位',
                duration: 3000
            });
            submitButton.style.pointerEvents = "auto"
            return;
        }
        api.showProgress({
            title: '保存中...',
        });


        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/createDistributionSaveNew";
        var data = {
            values: {
                relWorkCellGid: relWorkCellGid, // 调入库位
                list: JSON.stringify(arrSave),
                un: un,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                submitButton.style.pointerEvents = "auto"
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.data.code == '0') {
                    api.hideProgress();
                    api.toast({
                        msg: "保存成功",
                        duration: 3000
                    }); //清空表单


                    $("#workCellCode").val("");
                    workCellGid = "";
                    workCellCode = "";
                    workCellName = "";

                    var map = myobj.data;
                    for (var key in map) {
                        $("#" + key).html(map[key]);
                    }
                    $("#boxnum").attr('disabled', false);
                    $("#message").val(myobj.data.message);
                    $("#boxnum").focus();
                    idSelector = "boxnum";

                    //清空表格数据
                    $api.html($api.byId("tbodyHtml"), "");
                    $("#num").val(0);
                    $("#mrlnum").val(0);
                    arrSave = [];
                    num = 0;
                    mrlnum = 0;
                } else if (myobj.data.code == '1') {
                    $("#message").val("");
                    $("#boxnum").attr('disabled', false);
                    $("#boxnum").val("");
                    $("#boxnum").select();
                    idSelector = "boxnum";

                    flagMsg = "1";

                    arrSave = [];
                    num = 0;
                    mrlnum = 0;
                    var listE = myobj.data.listE
                    for (var j = 0; j < listE.length; j++) {
                        var model = {
                            mrlCode: listE[j].mrlCode, //物料号
                            lotCode: listE[j].lotCode, //批次号
                            qty: listE[j].qty, //转移数量
                            tm: listE[j].tm, //箱号
                            boxnum: listE[j].boxnum, //条码
                            tmID: listE[j].tmID, //条码ID
                            workCell: listE[j].workCell,
                            drawing: listE[j].drawing,
                            mrlName: listE[j].mrlName,
                            message: listE[j].message
                        }
                        arrSave.push(model);
                        num = num + 1;
                        mrlnum = mrlnum + parseFloat(listE[j].qty);
                    }
                    $("#num").val(num);
                    $("#mrlnum").val(mrlnum);
                    setTable(arrSave, flagMsg);
                    api.hideProgress();
                    api.toast({
                        msg: myobj.data.message,
                        duration: 3000
                    });

                }
            } else {
                submitButton.style.pointerEvents = "auto"
                $("#boxnum").attr('disabled', false);
                $("#boxnum").val("");
                $("#boxnum").select();
                idSelector = "boxnum";
                api.hideProgress();
                $("#message").val("");
                alert(JSON.stringify(err));
            }
        });
    }



    //自动保存
    function saveAuto(sm, mrlCode, lotCode, qty, boxnum, tmID) {
        //判断箱号是否重复
        for (var i = 0; i < arrSave.length; i++) {
            if (boxnum == arrSave[i].boxnum) {
                api.toast({
                    msg: '箱号已存在！',
                    duration: 3000
                });
                return;
            }
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCellByBoxnum";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                un: un,
                boxnum: boxnum,
                tm: sm,
                mrlCode: mrlCode,

            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            //   $("#boxnum").attr('disabled', false);
            //   $("#boxnum").select();
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {
                    api.hideProgress();
                    message = "提示信息：" + boxnum + "   扫描成功"
                    $("#message").val(message);
                    message = "";

                    var model = {
                        mrlCode: mrlCode, //物料号
                        lotCode: lotCode, //批次号
                        qty: qty, //转移数量
                        tm: sm, //箱号
                        boxnum: boxnum, //条码
                        tmID: tmID, //条码ID
                        workCell: myobj.workcell,
                        drawing: myobj.drawing,
                        mrlName: myobj.mrlName
                    }
                    var flag = "0";
                    for (var i = 0; i < arrSave.length; i++) {
                        if (boxnum == arrSave[i].boxnum) {
                            flag = "1";
                        }
                    }
                    if (flag == "0") {
                        arrSave.push(model);
                        num = num + 1;
                        mrlnum = mrlnum + parseFloat(qty);
                        $("#num").val(num);
                        $("#mrlnum").val(mrlnum);
                    }
                    setTable(arrSave);

                } else if (myobj.code == '1') {

                    api.hideProgress();
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });


    }

    function setTable(list, flagMsg) {//checkErrorBox为需要把边框变为红色的箱号
        var html = "";
        for (var i = 0; i < list.length; i++) {
            html += "<li class='sortable ui-selectee ui-sortable'>";
            html += "<div class='white_background'>"
            html += "<ul class='aui-list aui-media-list ui-selectee'>";
            html += "<li class='aui-list-item  ui-selectee'>";
            html += "<div class='aui-media-list-item-inner ui-selectee'>";
            html += "<div class='aui-list-item-inner ui-selectee'>";

            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>箱号</div>";
            html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].boxnum + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 20px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>物料编码</div>";
            html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].mrlCode + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>规格</div>";
            html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].drawing + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>物料名称</div>";
            html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].mrlName + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>数量</div>";
            html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].qty + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>批次</div>";
            html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].lotCode + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>调出库位</div>";
            html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].workCell + "</div>";
            html += "</div>";
            if (flagMsg == "1") {
                html += "<div class='aui-list-item-text ui-selectee' style='height: 32px;'>";
                html += "<div class='aui-list-item-label ui-selectee list-tr-title'>错误信息</div>";
                html += "<div class='aui-list-item-inner ui-selectee' style='font-size:0.65rem;'>" + list[i].message + "</div>";
                html += "</div>";
            }
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'></div>";
            html += "<div class='aui-list-item-inner ui-selectee'></div>";
            html += "<div class='aui-list-item-right aui-btn ui-selectee' style='background:red;color:#f5f5f5;' onclick='remove(\"" + list[i].boxnum + "\");'>移除</div>";
            html += "</div>";

            html += "</div>";
            html += "</div>";
            html += "</li>";
            html += "</ul>";
            html += "</div>";
            html += "</li>";
        }
        $api.html($api.byId("tbodyHtml"), html);
    };
    function remove(boxnum) {
        for (var i = 0; i < arrSave.length; i++) {
            if (arrSave[i].boxnum == boxnum) {
                num = num - 1;
                mrlnum = mrlnum - parseFloat(arrSave[i].qty);
                arrSave.splice(i, 1)
                $("#num").val(num);
                $("#mrlnum").val(mrlnum);
                setTable(arrSave, flagMsg);
            }

        }

    };


    function removeAll(list) {
        mrlnum = 0
        num = list.length;
        $("#num").val(num);
        for (var j = 0; j < list.length; j++) {
            mrlnum += parseFloat(list[j].qty);
        }
        $("#mrlnum").val(mrlnum);
        setTable(list);
        arrSave = list;
    };

    //扫描之后条码解析
    function tmSplit(sm) {
        // $("#tm").val(sm);
        //直接解析
        if (scanRule == "old") {

            //本地解析
            localAnalyze(sm);

        } else {

            //后台解析
            postAnalyze(sm);
        }
    }

    //本地解析
    function localAnalyze(sm) {
        var arr = sm.split(",");
        var mrlCode = "";
        if (arr[1] == null || arr[1] == undefined) {
            $("#mrlCode").val("");
        } else {
            mrlCode = arr[1];
        }
        var qty = "";
        if (arr[2] == null || arr[2] == undefined) {
            $("#qty").val("");
        } else {
            qty = arr[2];
        }
        var lotCode = "";
        if (arr[3] == null || arr[3] == undefined) {
            $("#lotCode").val("");
        } else {
            lotCode = arr[3];
        }
        var tmID = "";
        if (arr[4] == null || arr[4] == undefined) {
            $("#tmID").val("");
        } else {
            tmID = arr[4];
        }
        var boxnum = "";
        if (arr[9] == null || arr[9] == undefined) {
            $("#boxnum").val("");
        } else {
            boxnum = arr[9];
        }

        //自动入库
        saveAuto(sm, mrlCode, lotCode, qty, boxnum, tmID);
    }

    //后台解析条码
    function postAnalyze(sm) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/analysisBarCodeCommon";
        var data = {
            values: {
                tm: sm, //条码
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    var map = myobj.data;
                    for (var key in map) {
                        $("#" + key).val(map[key]);
                    }
                    $("#boxnum").val("");
                    //物料号
                    var mrlCode = map["mrlCode"];
                    //批次号
                    var lotCode = map["lotCode"];
                    //转移数量数量
                    var qty = map["qty"];
                    //条码
                    var tm = map["tm"];
                    //箱号
                    var boxnum = map["boxnum"];
                    //tmID
                    var tmID = map["tmID"];
                    // console.log(tm); 
                    //自动保存
                    saveAuto(tm, mrlCode, lotCode, qty, boxnum, tmID);
                } else if (myobj.code == '1') {
                    $("#boxnum").attr('disabled', false);
                    $("#boxnum").val("");
                    $("#boxnum").select();
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert(JSON.stringify(err));
            }
        });
    }


    //箱号监听回车事件
    $("#boxnum").on('keypress', function (e) { //#keyword为input文本框
        if (!clickThrottle()) {
            $("#boxnum").val("");
            return;
        }
        var keycode = e.keyCode;
        var tm = $(this).val();
        $("#boxnum").val("");
        if (keycode == '13') {
            if (tm != null && tm != "" && tm != undefined) {
                // $("#boxnum").blur();
                // $("#boxnum").attr('disabled', true);
                // console.log(tm);
                // $("#boxnum").select();
                //调用条码解析+保存事件
                tmSplit(tm);
            }
        }
    });

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>